package com.pb.wkflow.core.service;

import org.camunda.bpm.engine.impl.persistence.entity.DeploymentEntity;
import org.camunda.bpm.engine.repository.Deployment;
import org.camunda.bpm.engine.repository.ProcessDefinition;
import org.camunda.bpm.model.bpmn.BpmnModelInstance;

import java.util.List;

/**
 * 流程定义服务
 * @author 苗益辉
 * @date 2022/9/23 9:37
 */
public interface WorkflowDefinitionService {

    /**
     * 根据流程键值查询流程定义
     * @param processDefineKey 流程键值
     * @param tenantId 租户
     * @return List<ProcessDefinition>
     */
    List<ProcessDefinition> findListByProcessDefineKey(String processDefineKey, String tenantId);

    /**
     * 根据流程键值查询流程定义，最新版本
     * @param processDefineKey 流程键值
     * @param tenantId 租户
     * @return ProcessDefinition
     */
    ProcessDefinition findByProcessDefineKeyAndLastVersion(String processDefineKey, String tenantId);

    /**
     * 根据模型部署流程
     * @param processDefineKey 流程键值
     * @param modelInstance 模型
     * @param tenantId 租户
     * @return Deployment
     */
    Deployment deployByModel(String processDefineKey, BpmnModelInstance modelInstance, String tenantId);

    /**
     * 根据部署id查询部署信息
     * @param deploymentId 部署id
     * @return DeploymentEntity
     */
    DeploymentEntity findByDeploymentId(String deploymentId);

    /**
     * 查询租户下所有部署信息
     * @param tenantId 租户id
     * @return List<Deployment>
     */
    List<Deployment> findList(String tenantId);

    /**
     * 获取该节点是否是会签
     * @param modelInstance 流程定义id
     * @param activityId 当前节点
     * @return
     */
    String getIsMulti(BpmnModelInstance modelInstance, String activityId);

    /**
     * 获取模型
     * @param processDefineId 流程定义id
     * @return BpmnModelInstance
     */
    BpmnModelInstance findModel(String processDefineId);

    /**
     * 根据流程定义id获取流程信息
     * @param processDefineId 流程定义id
     * @return ProcessDefinition
     */
    ProcessDefinition findByProcessDefineId(String processDefineId);

    /**
     * 删除流程定义
     * @param procDefineId procDefineId
     */
    void deleteProcessDefine(String procDefineId);

}
